// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
exports.main = async(event, context) => {
  let _openid = event._openid
  let name = event.name
  let date = event.date
  let createDate = event.createDate
  let remark = event.remark
  console.log(context)
  try {
    return await db.collection('eventList').add({
      data: {
        _openid: _openid,
        name: name,
        date: date,
        createDate: createDate,
        remark: remark,
      }
    })
  } catch (e) {
    console.log(e)
  }
}